using System;
using System.Collections;
using System.Xml;

namespace FreeFlow.Client
{
	/// <summary>
	/// A collection of client script events.
	/// </summary>
	[Serializable]
	public class ClientScriptEvents
	{
    System.Collections.Generic.List<ClientScriptEvent> eventList =
      new System.Collections.Generic.List<ClientScriptEvent>();
    /// <summary>
    /// Creates a new <see cref="ClientScriptEvents"/> instance.
    /// </summary>
    /// <param name="eventListNode">The XML element contains the client script event list.</param>
		public ClientScriptEvents(XmlElement eventListNode)
		{
      if (eventListNode != null)
      {
        foreach (XmlElement eventNode in eventListNode)
        {
          ClientScriptEvent clientEvent = new ClientScriptEvent(eventNode);
          eventList.Add(clientEvent);
        }
      }
		}

    /// <summary>
    /// Gets the number of client scripts.
    /// </summary>
    public int Count
    {
      get
      {
        return eventList.Count;
      }
    }

    /// <summary>
    /// Gets the <see cref="ClientScriptEvent"/> at the specified index.
    /// </summary>
    public ClientScriptEvent this[int index]
    {
      get
      {
        return (ClientScriptEvent)eventList[index];
      }
    }
	}
}
